package com.yunxin.customui.service.handlerimpl.chart.asisHandlerImpl;

import cn.hutool.core.date.DateUtil;
import com.yunxin.customui.bean.echart.Axis;
import com.yunxin.customui.myinterface.chart.IAxisHandler;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 子时间axis处理程序
 *
 * @author LGY
 * @date 2021/10/11
 */
@Service("formatTime")
public class SubTimeAxisHandler implements IAxisHandler<String[]> {

    /**
     * 轴处理
     *
     * @param axis  直角坐标系轴 对象
     * @param param 参数
     */
    @Override
    public void axisHandle(Axis axis , String[] param) {
        List<String> handleResults = new ArrayList<>();
        List<String> data = axis.getData();
        for (String datum : data) {
            if (datum.trim().length()==10){
                datum +=" 00:00:00";
            }
            String format = DateUtil.format(DateUtil.parseDateTime(datum), param[0]);
            handleResults.add(format);
        }
        axis.setData(handleResults);

    }



}
